<template>
  <client-only>
    <el-collapse v-model="activeName" accordion>
      <div @click="routerChange('')">
        <el-collapse-item :title="$t('首页')" :name="1" class="no-child">
        </el-collapse-item>
      </div>
      <div @click="routerChange('productCenter')">
        <el-collapse-item :title="$t('产品中心')" :name="2" class="no-child">
        </el-collapse-item>
      </div>
      <!-- <el-collapse-item :title="$t('产品中心')" :name="2">
        <el-collapse v-model="activeName2" accordion>
          <el-collapse-item :title="$t('智能洗地机')" :name="2.1">
            <div class="swiper" v-swiper:productASwiper="productASwiperOption">
              <div class="swiper-wrapper">
                <div
                  class="swiper-slide"
                  v-for="item in productA"
                  :key="item.id"
                  @click.stop="
                    $router.push({
                      path: $i18n.path('productDetail/' + item.id),
                    })
                  "
                >
                  <img class="img" :src="item.thumb" alt="" />
                  <p class="text">{{ item.title }}</p>
                </div>
              </div>
            </div>
          </el-collapse-item>
          <el-collapse-item :title="$t('智能扫地机')" :name="2.2">
            <div class="swiper" v-swiper:productBSwiper="productBSwiperOption">
              <div class="swiper-wrapper">
                <div
                  class="swiper-slide"
                  v-for="item in productB"
                  :key="item.id"
                  @click.stop="
                    $router.push({
                      path: $i18n.path('productDetail/' + item.id),
                    })
                  "
                >
                  <img class="img" :src="item.thumb" alt="" />
                  <p class="text">{{ item.title }}</p>
                </div>
              </div>
            </div>
          </el-collapse-item>
          <el-collapse-item :title="$t('手持吸尘器')" :name="3.3">
            <div class="swiper" v-swiper:productCSwiper="productCSwiperOption">
              <div class="swiper-wrapper">
                <div
                  class="swiper-slide"
                  v-for="item in productC"
                  :key="item.id"
                  @click.stop="
                    $router.push({
                      path: $i18n.path('productDetail/' + item.id),
                    })
                  "
                >
                  <img class="img" :src="item.thumb" alt="" />
                  <p class="text">{{ item.title }}</p>
                </div>
              </div>
            </div>
          </el-collapse-item>
          <el-collapse-item :title="$t('干式吸尘器')" :name="4.4">
            <div class="swiper" v-swiper:productDSwiper="productDSwiperOption">
              <div class="swiper-wrapper">
                <div
                  class="swiper-slide"
                  v-for="item in productD"
                  :key="item.id"
                  @click.stop="
                    $router.push({
                      path: $i18n.path('productDetail/' + item.id),
                    })
                  "
                >
                  <img class="img" :src="item.thumb" alt="" />
                  <p class="text">{{ item.title }}</p>
                </div>
              </div>
            </div>
          </el-collapse-item>
        </el-collapse>
      </el-collapse-item> -->
      <div @click="routerChange('intelligentCleaningSolution')">
        <el-collapse-item
          :title="$t('智能清洁解决方案标题')"
          :name="3"
          class="no-child"
        >
        </el-collapse-item>
      </div>
      <div @click="routerChange('serviceSupport')">
        <el-collapse-item
          :title="$t('服务支持标题')"
          :name="4"
          class="no-child"
        >
        </el-collapse-item>
      </div>
      <el-collapse-item :title="$t('关于我们')" :name="5">
        <el-collapse v-model="activeName3" accordion>
          <p class="title" @click="routerChange('aboutUs', 0)">
            {{ $t("品牌简介") }}
          </p>
          <p class="title" @click="routerChange('aboutUs', 1)">
            {{ $t("核心技术") }}
          </p>
          <p class="title" @click="routerChange('aboutUs', 2)">
            {{ $t("新闻动态") }}
          </p>
          <p class="title" @click="routerChange('aboutUs', 3)">
            {{ $t("联系我们") }}
          </p>
        </el-collapse>
      </el-collapse-item>
      <a
        :href="
          $i18n.locale === 'cn'
            ? `/en${$route.fullPath}`
            : $route.fullPath.replace(/^\/[^\/]+/, '')
        "
        exact
      >
        <el-collapse-item title="中/EN" :name="6" class="no-child">
        </el-collapse-item>
      </a>
    </el-collapse>
  </client-only>
</template>

<script>
export default {
  data() {
    return {
      activeName: -1,
      activeName2: -1,
      activeName3: -1,
      productASwiperOption: {
        //指示点
        loop: false,
        autoplay: false,
        slidesPerView: "auto",
        spaceBetween: 7,
      },
      productBSwiperOption: {
        //指示点
        loop: false,
        autoplay: false,
        slidesPerView: "auto",
        spaceBetween: 7,
      },
      productCSwiperOption: {
        //指示点
        loop: false,
        autoplay: false,
        slidesPerView: "auto",
        spaceBetween: 7,
      },
      productDSwiperOption: {
        //指示点
        loop: false,
        autoplay: false,
        slidesPerView: "auto",
        spaceBetween: 7,
      },
      productA: [],
      productB: [],
      productC: [],
      productD: [],
    };
  },
  async fetch() {
    const res = await this.$indexApi.getGoodsList();
    // console.log(res.data);

    this.productA = res.data[0].list;
    this.productB = res.data[1].list;
    this.productC = res.data[2].list;
    this.productD = res.data[3].list;
  },
  methods: {
    routerChange(path, index) {
      this.$router.push({
        path: this.$i18n.path(path),
        query: {
          tabs: index,
        },
      });
      this.$emit("routerClick", true);
    },
  },
};
</script>

<style lang="less" scoped>
.swiper {
  margin-left: 30px;
  .swiper-wrapper {
    .swiper-slide {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 20px;
      width: 160px;
      background: #fafafa;
      box-sizing: border-box;
      padding: 20px 0;

      .img {
        width: 140px;
        height: 120px;
      }

      .text {
        font-size: 11px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #333333;
        margin: 0;
      }
    }
  }
}
.title {
  padding-left: 22px;
  margin-top: 0;
  margin-bottom: 20px;
}
:deep(.el-collapse-item__header) {
  font-size: 16px;
  &:hover {
    background: #ade1f5;
  }
}
</style>
